package com.zhangsr.zus.config.api;

import java.util.Arrays;
import java.util.List;

/**
 * @Author: zhangsr
 */
public abstract class AbstractServiceConfig extends AbstractConfig {

    // 服务版本
    protected String version;

    // 服务分组
    protected String group;

    protected List<ZusProtocolConfig> protocols;

    //------------------ setter && getter ------------------

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public List<ZusProtocolConfig> getProtocols() {
        return protocols;
    }

    public void setProtocols(List<? extends ZusProtocolConfig> protocols) {
        this.protocols = (List<ZusProtocolConfig>) protocols;
    }

    public ZusProtocolConfig getProtocol() {
        return protocols == null || protocols.size() == 0 ? null : protocols.get(0);
    }

    public void setProtocol(ZusProtocolConfig protocol) {
        this.protocols = Arrays.asList(new ZusProtocolConfig[]{protocol});
    }
}
